package com.lianxian.xindong.home.di.module;

import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.hxb.library.di.scope.FragmentScope;
import com.hxb.library.utils.AntiShakeUtils;
import com.lianxian.xindong.home.R;
import com.lianxian.xindong.home.mvp.contract.VideoContract;
import com.lianxian.xindong.home.mvp.model.VideoModel;
import com.lianxian.xindong.home.mvp.model.entity.VideoUserBean;
import com.lianxian.xindong.home.mvp.ui.weight.douyin.BaseRecAdapter;
import com.lianxian.xindong.home.mvp.ui.weight.douyin.ListVideoAdapter;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;


/**
 * @作者：hexingbo
 * @时间：07/02/2023
 * @描述：
 */
@Module
public abstract class VideoModule {

    @Binds
    abstract VideoContract.Model bindSelfieModel(VideoModel model);

    @FragmentScope
    @Provides
    static List<VideoUserBean> provideList() {
        return new ArrayList<>();
    }

    @FragmentScope
    @Provides
    static LinearLayoutManager provideLayoutManager(VideoContract.View view) {
        return new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false);
    }

    @FragmentScope
    @Provides
    static ListVideoAdapter provideAdapter(VideoContract.View view, List<VideoUserBean> list) {
        ListVideoAdapter adapter = new ListVideoAdapter(list);
        adapter.setItemClickListener(new BaseRecAdapter.onItemClickListener() {
            @Override
            public void onItemClick(BaseRecAdapter adapter, View v, int position) {
                if (AntiShakeUtils.isInvalidClick(v)) {
                    return;
                }
                if (v.getId() == R.id.iv_head) {
                    //头像
                    view.clickHead(list.get(position));
                } else if (v.getId() == R.id.iv_care) {
                    //关注
                    view.clickCare(list.get(position));
                } else if (v.getId() == R.id.tv_zan) {
                    //赞
                    view.clickZan(list.get(position));
                } else if (v.getId() == R.id.tv_msg_drop) {
                    //评论
                    view.clickMesDrop(list.get(position));
                } else if (v.getId() == R.id.iv_msg_hi) {
                    //聊天
                    view.clickMsgHi(list.get(position));
                } else if (v.getId() == R.id.iv_liwu) {
                    //礼物
                    view.clickLiWu(list.get(position));
                }
            }
        });
        return adapter;
    }
}